package com.liweiwei.role.service.serviceImpl;

import com.liweiwei.role.bean.RoleBean;
import com.liweiwei.role.dao.RoleDao;
import com.liweiwei.role.service.RoleService;
import com.liweiwei.role.util.DaoFactory;

import java.util.List;


public class RoleServiceImpl implements RoleService {
    private DaoFactory<RoleDao> daoFactory=new DaoFactory();
    private RoleDao roleDao = daoFactory.getDaoTransaction(RoleDao.class);


    @Override
    public Integer addRole(String name){
        roleDao.addRole(name);
        return 1;
    }

    @Override
    public Integer deleteRoleById(Integer id){
        roleDao.deleteRoleById(id);
        return 1;
    }

    @Override
    public Integer updateRoleById(Integer id, String name){
        roleDao.updateRoleById( id, name);
        return 1;
    }

    @Override
    public Integer findRoleById(Integer id){
        roleDao.findRoleById(id);
        return 0;
    }

    @Override
    public List<RoleBean> finAllRole(){
        daoFactory.getDao(RoleDao.class);
        return roleDao.findAllRole();

    }
}
